import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { WindowEvent } from "../../../component/window/WindowEvent";
import { Cache } from "../../cache/Cache";
import { ClockManager } from "../../manager/ClockManager";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ObjCreate } from "../common/ObjCreate";
import { SecTimerView } from "../common/SecTimerView";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { WrestleMainPanel } from "./WrestleMainPanel";
import { WrestleTopListPanel } from "./WrestleTopListPanel";
import { EWrestleOrderObjType } from "../../../../Message/Public/EWrestleOrderObjType";
import { WrestleVideoPanel } from "./WrestleVideoPanel";
import { PetHireInfoPanel } from "../petHire/PetHireInfoPanel";
import { PublicMessageConfig } from "../../resource/PublicMessageConfig";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { SWrestleOpen } from "../../../../Message/Public/SWrestleOpen";
import { MyWrestleInfo } from "./wrestleData/MyWrestleInfo";
import { SWrestleAccount } from "../../../../Message/Public/SWrestleAccount";
import { SWrestleToplists } from "../../../../Message/Public/SWrestleToplists";
import { SWrestleBattles } from "../../../../Message/Public/SWrestleBattles";
import { SWrestleFightRecordInfos } from "../../../../Message/Public/SWrestleFightRecordInfos";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class WrestleMainWindow
    
    export  class WrestleMainWindow extends BaseWindow
    {
        constructor()
        {
            this._tabBarData = [{"label": Language.getString(42315), "name":"mainPanel"}, {"label": Language.getString(42316), "name":"list1"}, {"label": Language.getString(42317), "name":"list2"}, {"label": Language.getString(42318), "name":"list3"}, {"label": Language.getString(42319), "name":"list4"}, {"label": Language.getString(42346), "name":"video"}];
            super();
            setSize(838, 555);
            titleHeight = 48;
            title = Language.getString(42234);
            this.addEventListener(WindowEvent.SHOW, this.onWindowShow);
            return;
        }

        /* internal  */onWindowShow(arg1: WindowEvent): void
        {
            var loc1=null;
            if (Cache.instance.wrestle.isOpen) 
            {
                loc1 = Cache.instance.wrestle.wrestleOpen;
                this._openTips.setLeftTime((loc1.closeDt.time - ClockManager.instance.nowDate.time) / 1000);
            }
            else 
            {
                this._openTips.text = Language.getString(42253);
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tabBar = new GTabBar();
            this._tabBar.horizontalGap = 1;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.dataProvider = this._tabBarData;
            this._tabBar.buttonWidth = 87;
            ObjCreate.setObjAttri(this._tabBar, 23, 34, -1, -1, this);
            this._openTips = new SecTimerView();
            this._openTips.defaultTextFormat = new GTextFormat(FontUtil.lishuName, 18, 15788607, false);
            this._openTips.text = Language.getString(42253);
            this._openTips.setParse(Language.getString(42340));
            this._openTips.filters = [FilterConst.glowFilter];
            this._openTips.mouseEnabled = false;
            ObjCreate.setObjAttri(this._openTips, 555, 32, 200, 22, this);
            this._btnHelp = ObjCreate.createGButton(Language.getString(42235), 750, 33, 70, 22, this, "Button");
            this._mainPanel = new WrestleMainPanel();
            this._mainPanel.x = 18;
            this._mainPanel.y = 60;
            this.addChild(this._mainPanel);
            this._topList1 = new WrestleTopListPanel(EWrestleOrderObjType._EWrestleOrderObjNormal, true);
            this._topList1.x = 18;
            this._topList1.y = 60;
            this._topList2 = new WrestleTopListPanel(EWrestleOrderObjType._EWrestleOrderObjNormal, false);
            this._topList2.x = 18;
            this._topList2.y = 60;
            this._topList3 = new WrestleTopListPanel(EWrestleOrderObjType._EWrestleOrderObjWeekHistory, true);
            this._topList3.x = 18;
            this._topList3.y = 60;
            this._topList4 = new WrestleTopListPanel(EWrestleOrderObjType._EWrestleOrderObjMonthHistory, false);
            this._topList4.x = 18;
            this._topList4.y = 60;
            this._viedoPanel = new WrestleVideoPanel();
            this._viedoPanel.x = 18;
            this._viedoPanel.y = 60;
            this._selectPanel = this._mainPanel;
            this._infoPanel = new PetHireInfoPanel();
            this._infoPanel.visible = false;
            this._infoPanel.x = 835;
            this._infoPanel.y = 40;
            var loc1=PublicMessageConfig.instance.getWrestleTextByName("wrestleHelpDesc");
            this._infoPanel.updateByContent(loc1);
            this.addChild(this._infoPanel);
            this.addListeners();
            return;
        }

        /* internal  */addListeners(): void
        {
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabChange);
            this._btnHelp.addEventListener(flash.events.MouseEvent.CLICK, this.onHelpBtn);
            return;
        }

        /* internal  */onTabChange(arg1: MuiEvent): void
        {
            var loc1=arg1.selectedIndex;
            var loc2=this.getPanelByIndex(loc1);
            if (this._selectPanel && this._selectPanel.parent) 
            {
                this._selectPanel.parent.removeChild(this._selectPanel);
            }
            this.addChild(loc2);
            this._selectPanel = loc2;
            return;
        }

        /* internal  */onHelpBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._infoPanel.visible = !this._infoPanel.visible;
            return;
        }

        /* internal  */getPanelByIndex(arg1: int): Object /* flash.display.DisplayObject */
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 0:
                {
                    return this._mainPanel;
                }
                case 1:
                {
                    return this._topList1;
                }
                case 2:
                {
                    return this._topList2;
                }
                case 3:
                {
                    return this._topList3;
                }
                case 4:
                {
                    return this._topList4;
                }
                case 5:
                {
                    return this._viedoPanel;
                }
                default:
                {
                    return this._mainPanel;
                }
            }
        }

        public open(arg1: SWrestleOpen): void
        {
            this._mainPanel.resetOpenState(true);
            this._openTips.setLeftTime((arg1.closeDt.time - ClockManager.instance.nowDate.time) / 1000);
            return;
        }

        public close(): void
        {
            this._mainPanel.resetOpenState(false);
            this._openTips.stop();
            this._openTips.text = Language.getString(42253);
            return;
        }

        public updateMyWrestleInfo(arg1: MyWrestleInfo): void
        {
            this._mainPanel.updateMyWrestleInfo(arg1);
            if (arg1.isNewCross) 
            {
                title = Language.getString(42359);
            }
            return;
        }

        public updateAccount(arg1: SWrestleAccount): void
        {
            this._mainPanel.updateAccount(arg1);
            return;
        }

        public updateTopList(arg1: SWrestleToplists): void
        {
            this._topList1.updateTopList(arg1);
            this._topList2.updateTopList(arg1);
            this._topList3.updateTopList(arg1);
            this._topList4.updateTopList(arg1);
            return;
        }

        public updateBattles(arg1: SWrestleBattles): void
        {
            this._mainPanel.updateBattles(arg1);
            return;
        }

        public updateSignUpState(arg1: Boolean): void
        {
            this._mainPanel.updateSignUpState(arg1);
            return;
        }

        public updateArenaMoney(arg1: int): void
        {
            this._mainPanel.updateMyArenaMoney(arg1);
            return;
        }

        public updateVideoList(arg1: SWrestleFightRecordInfos): void
        {
            this._viedoPanel.updateVideoList(arg1);
            return;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_openTips: SecTimerView;

        /* internal */ /* var */_selectPanel: Object /* flash.display.DisplayObject */;

        /* internal */ /* var */_tabBarData: Array<any>;

        /* internal */ /* var */_btnHelp: GButton;

        /* internal */ /* var */_infoPanel: PetHireInfoPanel;

        /* internal */ /* var */_mainPanel: WrestleMainPanel;

        /* internal */ /* var */_topList1: WrestleTopListPanel;

        /* internal */ /* var */_topList2: WrestleTopListPanel;

        /* internal */ /* var */_topList3: WrestleTopListPanel;

        /* internal */ /* var */_topList4: WrestleTopListPanel;

        /* internal */ /* var */_viedoPanel: WrestleVideoPanel;
    }
